﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public enum Balloon
{
    First,
    Second,
    Third,
    Fourth,
    Bullet,
    BossBullet,
    SmallGold,
    Boom,
}
public class GameTools : MonoBehaviour {
    public static GameTools instance;
	// Use this for initialization
	void Start () {
        instance = this;
	}

    public Dictionary<Balloon, List<GameObject>> Dic = new Dictionary<Balloon, List<GameObject>>();
    public GameObject GetGameobject(Balloon type)
    {
        GameObject obj = null;
        if (Dic.ContainsKey(type))
        {
            if (Dic[type].Count > 0)
            {
                obj = Dic[type][0];
                obj.SetActive(true);
                Dic[type].RemoveAt(0);
            }
            else
            {
                obj = GameObject.Instantiate(Resources.Load<GameObject>(type.ToString()));
            }
        }
        else 
        {
            obj = GameObject.Instantiate(Resources.Load<GameObject>(type.ToString()));
            List<GameObject> list = new List<GameObject>();
            Dic.Add(type, list);
        }
        return obj;
    }
    public void BackObj(GameObject obj,Balloon type) 
    {
        obj.SetActive(false);
        if (Dic.ContainsKey(type)) 
        {
            Dic[type].Add(obj);

        }
    }
	
}
